﻿// *************************************************************************************
// SCICHART® Copyright SciChart Ltd. 2011-2017. All rights reserved.
//  
// Web: http://www.scichart.com
//   Support: support@scichart.com
//   Sales:   sales@scichart.com
// 
// AnnotationsAreEasy.xaml.cs is part of the SCICHART® Examples. Permission is hereby granted
// to modify, create derivative works, distribute and publish any part of this source
// code whether for commercial, private or personal use. 
// 
// The SCICHART® examples are distributed in the hope that they will be useful, but
// without any warranty. It is provided "AS IS" without warranty of any kind, either
// expressed or implied. 
// *************************************************************************************
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using SciChart.Charting.Common.Helpers;
using SciChart.Charting.Visuals.Annotations;
using SciChart.Data.Model;

namespace SciChart.Examples.Examples.AnnotateAChart
{
    public partial class AnnotationsAreEasy : UserControl
    {
        public AnnotationsAreEasy()
        {
            InitializeComponent();
            sciChart.AnimateZoomExtentsCommand = new ActionCommand(OnZoomExtents);
            sciChart.MouseDoubleClick += OnSciChartMouseDoubleClick;
        }

        private void OnSciChartMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs)
        {
            OnZoomExtents();
        }

        private void TextAnnotation2_MouseClick(object sender, MouseEventArgs e)
        {
            ((TextAnnotation) sender).Text = "Clicked!";
        }

        private void TextAnnotation1_MouseEnter(object sender, MouseEventArgs e)
        {
            ((TextAnnotation)sender).Text = "Hovered!";
        }

        private void OnZoomExtents()
        {
            var range = new DoubleRange(0, 10);
            XAxis.AnimateVisibleRangeTo(range, TimeSpan.FromMilliseconds(500));
            YAxis.AnimateVisibleRangeTo(range, TimeSpan.FromMilliseconds(500));
        }
    }
}
